#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QTime>
#include <QTimer>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    mytimer = new QTimer(this);
    mytimer->setInterval(1000);

    connect(mytimer, SIGNAL(timeout()), this, SLOT(func()));
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    mytimer->start();
    func();
}


void MainWindow::func()
{
    QTime curTime = QTime::currentTime();
    ui->lcdNumber->display(curTime.toString("hh:mm:ss"));
}


void MainWindow::on_pushButton_2_clicked()
{
    mytimer->stop();
}

